package com.ruoyi.web.core.config;

import com.github.wxpay.sdk.WXPayConfig;
import org.apache.commons.io.IOUtils;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

public class WamiPayConfig extends WXPayConfig {
    private byte[] certData;

    /**
     * 获取证书内容
     * @throws IOException
     */
    public WamiPayConfig() throws IOException {
        InputStream certStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("static/cert/wami/apiclient_cert.p12");
        this.certData = IOUtils.toByteArray(certStream);
        certStream.close();
    }

    @Override
    public String getAppID() {
        return WamiConfig.APPID;
    }

    @Override
    public String getMchID() {
        return WamiConfig.MCHID;
    }

    @Override
    public String getKey() {
        return WamiConfig.KEY;
    }

    @Override
    public String getNotifyUrl() {
        return null;
    }

    @Override
    public InputStream getCertStream() {
        return new ByteArrayInputStream(this.certData);
    }
}
